package prickworlds.util;

public class Path {
	private String path;
	
	private static final String splitRegex = "/|\\\\";

	public Path(String path) {
		this.path = path;
	}

	public void removeLast() {
		String[] splits = path.split(splitRegex);
		String newPath = "";

		for (int i = 0; i < splits.length - 1; i++) {
			newPath += splits[i] + "/";
		}
		path = newPath;
	}

	public void add(Path b) {
		String[] splits = path.split(splitRegex);
		String[] splits2 = b.path.split(splitRegex);
		String newPath = "";
		for (int i = 0; i < splits.length; i++) {
			newPath += splits[i] + "/";
		}

		for (int i = 0; i < splits2.length; i++) {
			newPath += splits2[i];
			if (splits2.length > i + 1)
				newPath += "/";
		}
		path = newPath;
	}

	public String getString() {
		return path;
	}
}
